home *** CD-ROM | disk | FTP | other *** search
- Path: aed.aed-graphics.de!news
- From: Joerg Leinhoss <Leinhoss@AED-Graphics.DE>
- Newsgroups: comp.lang.c++
- Subject: g++2.7.2 bug
- Date: Wed, 03 Jan 1996 17:44:35 +0100
- Organization: AED Graphics GmbH
- Message-ID: <30EAB273.41C6@AED-Graphics.DE>
- NNTP-Posting-Host: aed21.aed-graphics.de
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0b3 (X11; I; OSF1 V3.2 alpha)
- CC: leinhoss
-
- Hi World,
- Which g++ version remove the following bug:
-
- test.cc:
-
- #include <stdio.h>
-
- int table[2][2][2] = {{{2,5}, {4,5}}, {{3,8}, {2,6}}};
-
- // #define output(i,j,k) printf("%d%d%d",i,j,k);
- #define output(i,j,k) printf("%d",table[i][j][k])
-
- void
- a() {
- for(int i=0; i<2; i++)
- output(i,0,0);
- for(i=0; i<2; i++)
- for(int j=0; j<2; j++)
- output(i,j,0);
- for(i=0; i<2; i++)
- for(int j=0; j<2; j++)
- for(int k=0; k<2; k++)
- output(i,j,k);
- }
-
-
- void
- b() {
- int i,j,k;
- for(i=0; i<2; i++)
- output(i,0,0);
- for(i=0; i<2; i++)
- for(j=0; j<2; j++)
- output(i,j,0);
- for(i=0; i<2; i++)
- for(j=0; j<2; j++)
- for(k=0; k<2; k++)
- output(i,j,k);
- }
-
- void
- main() {
- a(); putchar('\n');
- b(); putchar('\n');
- }
-
- //eof
-
- The functions a and b differs only in the function global declaration of i, j
- and k. One macro version makes a simple function call, the other make a array
- access with i, j and k. Both functions should produce the same result with both
- output macros!
-
- While compiling g++2.7.2 warns:
- test.cc: In function `void a()':
- test.cc:12: warning: name lookup of `i' changed for new ANSI `for' scoping
- test.cc:10: warning: using obsolete binding at `i'
-
- Ok, I know what this means. No Comment.
-
- The output compiled with the first output-define is
- 000100000010100110000001010011100101110111
- 000100000010100110000001010011100101110111
- ... all correct.
-
- But the output compiled with the second-define is
- 23222526
- 23243225453826
- ... the bug !?
-
- Which option can prevent this bug ? Which g++ version removes it ?
-
- Joerg Leinhoss
- (Please no emails, post the replys to this newsgroups)
-